package com.lsc.record.controller;

import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.JSONArray;
import com.mybatisflex.core.paginate.Page;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;

import java.util.List;
/**
 * 基本api模版
 * @param <T>
 */
public abstract class ApiBaseController<T> {
    /**
     * 保存数据对象
     *
     * @param data
     * @return
     */
    @PostMapping("save")
    public abstract String save(T data)  throws Exception;

    /**
     * 获取数据对象
     *
     * @param id
     * @return
     */
    @GetMapping("get")
    public abstract T get(String id)  throws Exception;

    /**
     * 数据查询分页
     *
     * @param limit
     * @param page
     * @param condition
     * @return
     */
    @PostMapping("page")
    public abstract Page<T> page(int pageSize, int pageIndex, JSONObject condition)  throws Exception;

    /**
     * 获取数据查询列表
     *
     * @param condition
     * @return
     */
    @PostMapping("list")
    public abstract List<T> list(JSONObject condition) throws Exception;

    /**
     * 数据更新
     *
     * @param data
     * @return
     */
    @PutMapping("update")
    public abstract Boolean update(T data) throws Exception;

    /**
     * 数据删除
     *
     * @param id
     * @return
     */
    @DeleteMapping("delete")
    public abstract Boolean delete(String id) throws Exception;


}
